<?php
require_once('checklogin.php');
require_once('classQuanTriTin.php');
$qt = new quantritin;	
$idNurse=-1; if (isset($_GET['idNurse'])==true) $idNurse = $_GET['idNurse']; settype($idNurse,"int");

	$pageSize = 4; //pageSize: số trang hiện ra trên trình duyệt: 1|2|3|4|5
	$pageNum = 1; //pageNum: số trang
	if (isset($_GET['pageNum'])==true) $pageNum = $_GET['pageNum'];
	settype($pageNum,"int");
$nurse = $qt->ListNurse($idNurse,$pageNum,$pageSize);
$totalRows = $qt->CountNurse();
//echo "<p>".$totalRows."</p>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>List Nurse</title>
<style>
#dstin th {
	color: #333333;
	background-image: url(../images/admin_label.jpg);
	background-repeat: repeat-x;
	height: 25.5px;
	width: auto;
	text-align: center;
}
#dstin {
	width: 90%;
	border-bottom-width: 2px;
	border-bottom-style: dotted;
	border-bottom-color: #61DD03;
	float: left;
}
.ngay {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
}
.tin p{
	margin-top: 5px;
	margin-bottom: 5px;
	text-align: justify;
	color: #C60;
	text-transform: uppercase;
}
.tieude_customer {
	font-weight: bold;
	color: #C60;
}
.infor_trai {
	height: 100%;
	width: 30%;
}
.ghichu {
	width: 550px;
	text-transform: lowercase;
	color: #666;
	font-style: italic;
}
.tin p:first-child{font-weight:bold; color:#C60;}
.infor_tieude {
	font-weight: bold;
	color: #C60;
	border-bottom-width: 1px;
	border-bottom-style: dotted;
	border-bottom-color: #000;
	text-transform: uppercase;
}
.tin p:first-child span{ font-style:italic; color:#060; font-size:14px}
p.tomtat:first-line { color:#06C}
p.tomtat:first-letter { font-size:22px; color:#C0C; font-weight:bold}
.action a{ color:#033; text-decoration:none}
.action a:hover{ color:#630; text-decoration:underline}
.hightlight {
	background-image: url(../images/admin_hover.png);
	background-repeat: repeat-y;
}
.them {	font-weight: bold;color: #FFFFFF; background-color: #FF9900;
		display: block; height: 22px; width: 50px; text-decoration: none;
		line-height: 22px; font-size: 14px; text-align: center; float:left;
}
.themtin {float: left; width: 50px;}
.hang {
	border-bottom-width: 3px;
	border-bottom-style: dotted;
	border-bottom-color: #FF0000;
}
<!--
	#pageList a {
	background-color:#333333;
	color:#FFFFFF;
	padding-left:5px;
	padding-right:5px;
	margin-left:5px;
	text-decoration:none;
	border: 1px dotted #999999;
	font-size: 12px;
	font-family: Arial, Helvetica, sans-serif;
	}
	#pageList a:hover{
		background-color:#FFA8A8;
		color:#000000;
		font-family: Arial, Helvetica, sans-serif;
	}
	#first a{
	background-image: url(icon_first.png);
	text-decoration: none;
	}
	#first a:hover{
	background-image: url(icon_first_hover.png);
	text-decoration: none;
	}
	#last a{
	background-image: url(icon_last.png);
	text-decoration: none;
	}
.col {
	width: 60px;
}
	#last a:hover{
	background-image: url(icon_last_hover.png);
	text-decoration: none;
	}
	#prev a{
	background-image: url(icon_prev.png);
	text-decoration: none;
	}
	#prev a:hover{
	background-image: url(icon_prev_hover.png);
	text-decoration: none;
	}
	#next a{
	background-image: url(icon_next.png);
	text-decoration: none;
	}
	#next a:hover{
	background-image: url(icon_next_hover.png);
	text-decoration: none;
	}
	.pageListSpan{
		padding-left:5px;
		padding-right:5px;
		margin-left:5px;
		background-color:#FF0000;
		font-weight: bold;
		color: #CCCCCC;
		border: 1px dotted #400000;
		font-family: Arial, Helvetica, sans-serif;
	}
	-->
    .hang_le {
	background-color: #a3d6f3;
    }
    .hang_chan {
	background-color: #fac7da;
    }
.email {
	text-transform: lowercase;
}
#mahs {
	font-weight: bold;
	color: #666;
}
</style>
<script type="text/javascript" src="../Scripts/jquery.js"></script>

<script>
$(document).ready(function(){

	$("img.career").click(function(){
		idNurse=$(this).attr("value");
		obj = this;
		$.ajax({
		   url:'nurse_career.php',
		   data: 'idNurse='+ idNurse,
		   cache: false,
		   success: function(data){ //Biến data khai báo tên khác cũng được, dùng để nhận dữ liệu đổ về
			obj.src = data;
			if (data=="Career_1.png") obj.title="*CỘNG TÁC VIÊN* - Click để chuyển sang NỮ HỘ SINH";
			else obj.title="*NỮ HỘ SINH* - Click để chuyển CỘNG TÁC VIÊN";
		  }
		});
	});

	$("img.sex").click(function(){
		idNurse = $(this).attr("value");
		obj = this;
		$.ajax({
		   url:'nurse_sex.php',
		   data: 'idNurse='+ idNurse,
		   cache: false,
		   success: function(data){
			obj.src = data;
			if (data=="Sex_1.png") 
				obj.title="*NỮ* - Click để chuyển giới tính sang NAM";
			else  obj.title="*NAM* - Clieck để chuyển giới tính sang NỮ";
		   }
		});
	});

	$("img.anhien").click(function(){
		idNurse=$(this).attr("value");
		obj = this;
		$.ajax({
		   url:'nurse_anhien.php',
		   data: 'idNurse='+ idNurse,
		   cache: false,
		   success: function(data){ //Biến data khai báo tên khác cũng được, dùng để nhận dữ liệu đổ về
			obj.src = data;
			if (data=="AnHien_1.gif") obj.title="Nhắp vào để ẩn nữ hộ sinh";
			else obj.title="Nhắp vào để hiện nữ hộ sinh";
		  }
		});
	});

	$("#chonhet").click(function(){
		var status = this.checked;
		$("input[name='chon']").each(function(){this.checked=status;})
	});
	$("#hang").mouseover(function(){ $(this).addClass("hightlight");  });
	$("#hang").mouseout(function(){	 $(this).removeClass("hightlight"); });
	$("#xoahet").click(function(){
		var listid = "";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid + "," + this.value;
	   })
		listid = listid.substr(1);	 //alert(listid);
		if (listid=="") { alert("Bạn chưa chọn tin nào"); return;}
		hoi= confirm("Xoá hết hả");
		if (hoi==true) document.location = "account_xoa.php?listid=" + listid;
	});
	$("#chinhhet").click(function(){
		var listid = "";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid + "," + this.value;
		});
		listid = listid.substr(1);	 //alert(listid);
		if (listid=="") { alert("Bạn chưa chọn tin nào"); return;}
		document.location = "tintuc_chinhhet.php?listid=" + listid;
	});



});
</script>	
<script>
$(document).ready(function(){
	$(".row:even").css("background-color","#e8f3f9");
	$(".row:odd").css("background-color", "#fdecf2");
	//$(".col:even").css("background-color","#009100");
	//$(".col:odd").css("background-color", "#6F6F6F");
	$(".col:even").addClass("hang_le");
	$(".col:odd").addClass("hang_chan");
});
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table id=dstin  border=0 cellpadding=4 cellspacing=0  width=87%  align=left>
<tr>
  <td width="60" align="left">&nbsp;</td>
  <td colspan="2" align="center"><p align="center" id="thanhphantrang"><?php echo $qt->pagesListLink($totalRows, $pageNum, $pageSize);?></p></td>
  <td align="right">&nbsp;</td>
  <td align="right"> 
  
<select name="themtin" class="themtin" id="themtin">
    <option value="1">1</option> <option value="2">2</option>
    <option value="3">3</option> <option value="4">4</option>
    <option value="5">5</option>
</select>


<a href="main.php?p=nurse_add" onClick="return true" class="them" id="them">Thêm</a></td>
</tr>
<tr>
   <th height="93" align="left">
   <!-- Hide checkbox  <input type="checkbox" name="chonhet" id="chonhet" /> --> Code</th>
   <th width="114"><div align="left">Nurse</div></th>
   <th width="601"><div align="left"><span class="user">Information</span></div></th>
   <th>Status</th>
   <th> Action </th>
</tr>

<!—bắt đầu lặp -->

<?php 

	while ($row_nurse = mysql_fetch_assoc($nurse) ) { 
	
?>
<?php ob_start(); ?>

<tr class="row">
	
   <td class="col"><div id="mahs" align="center">
   <!-- Hide checkbox  <input type="checkbox" name="chon" id="chon" value="{idNurse}" class="chon" />-->
   {idNurse}
   </div></td>
   
   <td valign="top" class="tin">
     <p class="user">{TenHS}</pp></td>
   <td align="left" valign="top" class="tin">
     <p class="infor_tieude">Thông tin nữ hộ sinh:</p>
     <table id="infor" width="100%" border="0" cellspacing="0" cellpadding="0">
       <tr>
         <td align="left" class="infor_trai">Địa chỉ</td>
         <td>{Sonha} {Duong}, {Phuong}, {Quan}</td>
         </tr>
       <tr>
         <td>Email</td>
         <td class="email">{Email}</td>
         </tr>
       <tr>
         <td>Số điện thoại</td>
         <td>{Phone}</td>
         </tr>
       <tr>
         <td>Ngày sinh</td>
         <td><//?=date('d/m/Y',strtotime($row_nurse['bday']))?>
         <?
           $bday=date('d/m/Y',strtotime($row_nurse['bday']));
           if ($bday=='01/01/1970'){ echo 'Chưa nhập ngày'; }
           else echo $bday;
         ?>
         </td>
       </tr>
       <tr>
         <td>&nbsp;</td>
       </tr>
       </table>
     <p class="infor_tieude">ghi chú</p>
     <table id="infor2" width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
     	<td class="ghichu">
        <?php
		$ghichu= $row_nurse['summary']; 
		if (!empty($ghichu)){ echo $ghichu; }
		else { echo "Không có ghi chú"; }
		?>
        </td>
     </tr>
     </table></td>
   <td width="85" align="center" valign="top" class="action">
     <?php 
	 //Show aldult status
	 $gender_aldult= $row_nurse['sex']; 
	 if ($gender_aldult==1){ $p="Anh"; } 
	 else { $p="Chị"; } 
	 ?>
     <img src="Gender_{Gender_aldult}.png" title="<?php /*Show aldult status*/ echo $p; ?>" class="no_class" value="{idNurse}" />
     <p>
     <?php 
	 //Show career status
	 $career= $row_nurse['career']; 
	 if ($career==1){ $p="Cộng tác viên"; } 
	 else { $p="Nữ hộ sinh"; } 
	 ?>
     <img src="Career_{career}.png" title="<?php /*Show career status*/ echo $p; ?>" class="career" value="{idNurse}" />
     </p>
     <p>
     <?php 
			//Show AnHien status
			$AnHien= $row_nurse['hide']; 
			if ($AnHien==1){ $p="Hiện"; } 
			else { $p="Ẩn"; } 
	 ?>
     <img src="AnHien_<?php echo $AnHien; ?>.gif" title="<?php /*Show AnHien status*/ echo $p; ?>" class="anhien" value="{idNurse}" />
     </p>
   </td>
   <td width="104" align="center" valign="top" class="action"><a href="main.php?p=nurse_edit&idNurse={idNurse}"><img src="icon_edit.png" class="images" /></a><a href="nurse_delete.php?idNurse={idNurse}" onclick="return confirm('Bạn muốn xoá hộ sinh {TenHS} ???');"><img src="icon_trash.png" class="images" /></a></td>
</tr>
<?php 	
$str = ob_get_clean(); 
$str = str_replace("{idNurse}",$row_nurse['idNurse'],$str);
$str = str_replace("{TenHS}",$row_nurse['TenHS'],$str);
$str = str_replace("{Sonha}",$row_nurse['number'],$str);
$str = str_replace("{Duong}",$row_nurse['street'],$str);
$str=str_replace("{Phuong}", $row_nurse['t_ward'] , $str);
$str=str_replace("{Quan}", $row_nurse['t_district'] , $str);
$str = str_replace("{Email}",$row_nurse['email'],$str);
$str=str_replace("{Phone}", $row_nurse['phone'] , $str);
$str=str_replace("{Bday}", $row_nurse['bday'] , $str);

//$str=str_replace("{GhiChu}", $row_nurse['summary'] , $str);
$str=str_replace("{Gender_aldult}", $row_nurse['sex'] , $str);
$str=str_replace("{career}", $row_nurse['career'] , $str);
echo $str;
?>
<?php } //while ?>
<!— kết thúc lặp -->

</table>
</form>
</body>
</html>
